<div class="container container-gary">
    <!-- member index -->
    <div class="m-ptb wrap clearfix">
{include file="common@public/_personal_left"}
          <div class="member-right">
              <div class="member-sign clearfix">
                  <b>我的信息</b>
                  <div class="address-span">
                    <input class="address-s-color" type="button" value="保存" id="btn"/>
                      <a href="javascript:history.back(-1)"><input type="button" value="取消"/></a>
                 </div>
              </div>
              <div class="member-order min-height">
                  <div class="member-t-gary clearfix">
                      <h3>发票资质基础资料修改</h3>
                  </div>
                  <div class="m-safe-info">
                      <div class="m-safe-enter clearfix">
                          <div class="m-safe-txt">发票类型：</div>
                          <div class="m-safe-right">
                              <div><select class="company-select" id="type">
                                  <option value="">请选择发票类型</option>
                                  {foreach name="invoicetype" item="vo"}
                                  {if condition="$balance.invoice_type eq $vo.invoice_id"}
                                  <option value="{$vo.invoice_id}" selected="selected">{$vo.invoice_type}</option>
                                  {else /}
                                  <option value="{$vo.invoice_id}">{$vo.invoice_type}</option>
                                  {/if}
                                  {/foreach}
                              </select>
                              </div>
                              <div class="invoice-gary">
                              选择增值税发票，单位名称、纳税人识别号、 注册地址、电话、开户银行、银行帐号都必须填写。 选择普通增值税发票仅需填写单位名称
                              </div>
                              <span id="invoice" style="color: red" class="enter-prompt"></span>
                          </div>
                      </div>
                      <div class="m-safe-enter clearfix">
                          <div class="m-safe-txt">单位名称：</div>
                          <div class="m-safe-right">
                              <input class="safe-input safe-w1" type="text" placeholder="" id="company" value="{$balance.company}"/>
                              <span id="companyname" style="color: red" class="enter-prompt"></span>
                          </div>
                      </div>
                      <div id="contents" {if condition="$balance.invoice_type eq 2"} style="display: none"{/if}>
                      <div class="m-safe-enter clearfix" id="divname">
                          <div class="m-safe-txt">银行开户名：</div>
                          <div class="m-safe-right">
                              <input class="safe-input safe-w1" type="text" placeholder="" id="name" value="{$balance.accountname}"/>
                              <span id="bankusername" style="color: red" class="enter-prompt"></span>
                          </div>
                      </div>
                      <div class="m-safe-enter clearfix" id="divtel">
                          <div class="m-safe-txt">手机号码：</div>
                          <div class="m-safe-right">
                              <input class="safe-input safe-w1" type="text" placeholder="" id="tel" value="{$balance.mobile}"/>
                              <span id="mobile" style="color: red" class="enter-prompt"></span>
                          </div>
                      </div>
                      <div class="m-safe-enter clearfix" id="divbank">
                          <div class="m-safe-txt">开户银行：</div>
                          <div class="m-safe-right">
                              <input class="safe-input safe-w1" type="text" placeholder="" id="bankname" value="{$balance.bankname}"/>
                              <span id="bank" style="color: red" class="enter-prompt"></span>
                          </div>
                      </div>
                      <div class="m-safe-enter clearfix" id="divno">
                          <div class="m-safe-txt">纳税人识别号：</div>
                          <div class="m-safe-right">
                              <input class="safe-input safe-w1" type="text" placeholder="纳税人识别号" id="taxpayer_no" value="{$balance.taxpayer_no}"/>
                              <span id="peopleid" style="color: red" class="enter-prompt"></span>
                          </div>
                      </div>
                      <div class="m-safe-enter clearfix" id="divbankid">
                          <div class="m-safe-txt">支行联行号：</div>
                          <div class="m-safe-right">
                              <input class="safe-input safe-w1" type="text" placeholder="支行联行号" id="bankid" value="{$balance.bankid}"/>
                              <span id="subbranch" style="color: red" class="enter-prompt"></span>
                          </div>
                      </div>
                      <div class="m-safe-enter clearfix" id="address">
                          <div class="m-safe-txt">开户行地址：</div>
                          <select class="enter-select" id="c_province" name="c_province" onchange="region.changed(this, 2, 'c_city')" style="margin-left: 7px">
                              <option value="">请选择</option>
                              {foreach name="list_province" item="vo"}
                              <option value="{$vo.id}" {if condition="isset($balance.c_provinceid) && ($vo.id eq $balance.c_provinceid)"}selected{/if}>{$vo.name}</option>
                              {/foreach}
                          </select>
                          <select class="enter-select" id="c_city" name="c_city" onchange="region.changed(this, 3, 'c_area')">
                              <option value="">请选择</option>
                              {if condition="isset($c_city)"}
                              {foreach $c_city as $vo}
                              <option value="{$vo.id}" {if condition="$vo.id eq $balance.c_cityid"}selected{/if}>{$vo.name}</option>
                              {/foreach}
                              {/if}
                          </select>
                          <select class="enter-select" id="c_area" name="c_area">
                              <option value="">请选择</option>
                              {if condition="isset($c_area)"}
                              {foreach $c_area as $vo}
                              <option value="{$vo.id}" {if condition="$vo.id eq $balance.c_townid"}selected{/if}>{$vo.name}</option>
                              {/foreach}
                              {/if}
                          </select>
                          <span id="c_companyplace" style="color: red" class="enter-prompt"></span>
                      </div>
                      <div class="m-safe-enter clearfix" id="divbankaddr">
                          <div class="m-safe-txt">开户行所在地：</div>
                          <div class="m-safe-right">
                              <input class="safe-input safe-w1" type="text" placeholder="开户行所在地" id="bandaddr" value="{$balance.bandaddr}"/>
                              <span id="bankaddr" style="color: red" class="enter-prompt"></span>
                          </div>
                      </div>
                      <div class="m-safe-enter clearfix" id="signaddr">
                          <div class="m-safe-txt">注册地址：</div>
                          <select class="enter-select" id="province" name="province" onchange="region.changed(this, 2, 'city')" style="margin-left: 7px">
                              <option value="">请选择</option>
                              {foreach name="list_province" item="vo"}
                              <option value="{$vo.id}" {if condition="isset($balance.provinceid) && ($vo.id eq $balance.provinceid)"}selected{/if}>{$vo.name}</option>
                              {/foreach}
                          </select>
                          <select class="enter-select" id="city" name="city" onchange="region.changed(this, 3, 'area')">
                              <option value="">请选择</option>
                              {if condition="isset($city)"}
                              {foreach $city as $vo}
                              <option value="{$vo.id}" {if condition="$vo.id eq $balance.cityid"}selected{/if}>{$vo.name}</option>
                              {/foreach}
                              {/if}
                          </select>
                          <select class="enter-select" id="area" name="town">
                              <option value="">请选择</option>
                              {if condition="isset($area)"}
                              {foreach $area as $vo}
                              <option value="{$vo.id}" {if condition="$vo.id eq $balance.townid"}selected{/if}>{$vo.name}</option>
                              {/foreach}
                              {/if}
                          </select>
                          <span id="companyplace" style="color: red" class="enter-prompt"></span>
                      </div>
                      <div class="m-safe-enter clearfix" id="divaddr">
                          <div class="m-safe-txt">注册详细地址：</div>
                          <div class="m-safe-right">
                              <input class="safe-input safe-w1" type="text" placeholder="注册地址" id="signup_address" value="{$balance.signup_address}"/>
                              <span id="signinaddr" style="color: red" class="enter-prompt"></span>
                          </div>
                      </div>
                    </div>
                  </div>
              </div>
          </div>
      </div>

  </div>

  <!-- footer -->
  <!--#include file="includes/foot.html"-->

<!-- menu -->
<script type="text/javascript" src="/public/static/home/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="/public/static/home/js/menu.js"></script>
<script src="/public/static/home/js/region.js?r=1"></script>
<script src="/public/static/home/js/icheck.js"></script>
<script>
    $('#type').change(function() {
        var type=$('#type').val();
        if(type==2){
            document.getElementById('contents').style.display="none";
        }else{
            document.getElementById('contents').style.display="";
        }
    });
    $('#type').blur(function() {
        $("#invoice").text("");
    });
    $('#company').blur(function() {
        $("#companyname").text("");
    });
    $('#name').blur(function() {
        $("#bankusername").text("");
    });
    $('#tel').blur(function() {
        $("#mobile").text("");
    });
    $('#bankname').blur(function() {
        $("#bank").text("");
    });
    $('#taxpayer_no').blur(function() {
        $("#peopleid").text("");
    });
    $('#bankid').blur(function() {
        $("#subbranch").text("");
    });
    $('#bandaddr').blur(function() {
        $("#bankaddr").text("");
    });
    $('#signup_address').blur(function() {
        $("#signinaddr").text("");
    });
    $('#c_province').blur(function() {
        $("#c_companyplace").text("");
    });
    $('#c_city').blur(function() {
        $("#c_companyplace").text("");
    });
    $('#city').blur(function() {
        $("#companyplace").text("");
    });
    $('#province').blur(function() {
        $("#companyplace").text("");
    });
    $('#btn').click(function() {
        var type=$('#type').val();
        var company=$('#company').val();
        var name=$('#name').val();
        var tel=$('#tel').val();
        var bankname=$('#bankname').val();
        var taxpayer_no=$('#taxpayer_no').val();
        var bankid=$('#bankid').val();
        var c_province=$('#c_province').val();
        var c_city=$('#c_city').val();
        var c_area=$('#c_area').val();
        var province=$('#province').val();
        var city=$('#city').val();
        var area=$('#area').val();
        var bandaddr=$('#bandaddr').val();
        var signup_address=$('#signup_address').val();
        if(type==''){
            $('#invoice').text('请选择发票类型');
            document.getElementById('type').focus();
            return false;
        }else{
            if(type==2){
              if(company=='' || company==' '){
                  $('#companyname').text('请填写单位名称');
                  document.getElementById('company').focus();
                  return false;
              }else{
                  $.ajax({
                      url:"{:url('member/Memberinfo/invoiceEdit')}",
                      type:"post",
                      data:{'type':type,'company':company},
                      success:function (data) {
                          if(data=='1'){
                              window.location.href="{:url('member/Memberinfo/index')}";
                          }else{
                              $('#invoice').text('更新失败');
                              document.getElementById('type').focus();
                          }
                      }
                  });
              }
            }else{
                if(company=='' || company==' ') {
                    $('#companyname').text('请填写单位名称');
                    document.getElementById('company').focus();
                    return false;
                }else if(name=='' || name==' '){
                    $('#bankusername').text('请填写银行开户名');
                    document.getElementById('name').focus();
                    return false;
                }else if(tel=='' || tel==' '){
                    $('#mobile').text('请填写手机号码');
                    document.getElementById('tel').focus();
                    return false;
                }else if(bankname=='' || bankname==' '){
                    $('#bank').text('请填写开户银行');
                    document.getElementById('bankname').focus();
                    return false;
                }else if(taxpayer_no=='' || taxpayer_no==' '){
                    $('#peopleid').text('请填写纳税人识别号');
                    document.getElementById('taxpayer_no').focus();
                    return false;
                }else if(bankid=='' || bankid==' ') {
                    $('#subbranch').text('请填写支行联行号');
                    document.getElementById('bankid').focus();
                    return false;
                }else if(c_province=='') {
                    $('#c_companyplace').text('请选择所属省份');
                    document.getElementById('c_province').focus();
                    return false;
                }else if(c_city=='') {
                    $('#c_companyplace').text('请选择所属城市');
                    document.getElementById('c_city').focus();
                    return false;
                }else if(bandaddr=='' || bandaddr==' ') {
                    $('#bankaddr').text('请输入开户行所在地');
                    document.getElementById('bandaddr').focus();
                    return false;
                }else if(province=='') {
                    $('#companyplace').text('请选择所属省份');
                    document.getElementById('province').focus();
                    return false;
                }else if(city=='') {
                    $('#companyplace').text('请选择所属城市');
                    document.getElementById('city').focus();
                    return false;
                }else if(signup_address=='' || signup_address==' ') {
                    $('#signinaddr').text('请输入注册详细地址');
                    document.getElementById('signup_address').focus();
                    return false;
                }else{
                    $.ajax({
                        url:"{:url('member/Memberinfo/invoiceEdit')}",
                        type:"post",
                        data:{'type':type,'company':company,'name':name,'tel':tel,'bankname':bankname,'c_province':c_province,
                            'c_city':c_city,'c_area':c_area,'province':province,'city':city,'area':area,
                            'taxpayer_no':taxpayer_no,'bankid':bankid,'bandaddr':bandaddr,'signup_address':signup_address},
                        success:function (data) {
                            if(data=='1'){
                                window.location.href="{:url('member/Memberinfo/index')}";
                            }else if(data=='2'){
                                $('#invoice').text('更新失败');
                                document.getElementById('type').focus();
                            }else{
                                $('#mobile').text('手机号码格式不正确');
                                document.getElementById('tel').focus();
                            }
                        }
                    });
                }
            }
        }

    });
    $(function(){
      //top select
      $(".top-select").mouseover(function () {
        $(".top-s-text").show();
      })
      $(".top-select").mouseout(function () {
        $(".top-s-text").hide();
      })
      $(".top-s-text div").click(function () {
        var selecttext = $(this).text();
        $(".top-s-head span").text(selecttext);
        $(this).parent(".top-s-text").hide()
      })
      // top code
      var turn = function(target,time,opts){
      target.find('.top-code').hover(function () {
            $(this).find('.top-c-img').stop().animate(opts[0], time, function () {
			$(this).hide().next().show();
			$(this).next().animate(opts[1],time);
	   });
	   },function(){
	        $(this).find('.top-c-text').animate(opts[0], time, function () {
			    $(this).hide().prev().show();
			    $(this).prev().animate(opts[1],time);
		 });
	     });
        }
        var verticalOpts = [{'width':0},{'width':'80px'}];
        turn($('.top-right'), 150, verticalOpts);
        //menu all
        $(".menu-all div").mouseenter(function () {
            $(this).addClass("current");
            $(".submenu").show();
        })
       $(".menu-all div").mouseleave(function () {
            $(this).removeClass("current");
            $(".submenu").hide();
        })
        $(".submenu").mouseenter(function(){
           $(this).show();
           $(".menu-all div").addClass("current")
        })
        $(".submenu").mouseleave(function(){
           $(this).hide();
           $(".menu-all div").removeClass("current")
        })
        //left submenu
        $(".submenu ul li").each(function () {
            var $this = $(this);
            var $children = $this.find('.submenu-pro');
            var $otherChildren = $this.siblings('li').find('.submenu-pro');
            var $childrenList = $children.children('.submenu-total');
            $this.on({
                'mouseenter': function () {
                    $children.css({ 'display': 'block', 'width': 221 * parseInt($childrenList.size()) });
                    $otherChildren.css('display', 'none');
                },
                'mouseleave': function () {
                    $children.css('display', 'none');
                }
            })
        });

        //member left
        $(".member-l-title").click(function(){
           $(this).parent(".member-l-list").toggleClass("m-current");
           $(this).parent(".member-l-list").find("ul").slideToggle()
        })
    })
</script>
</body>
</html>